import { defineConfig } from "vite";
import reactRefresh from "@vitejs/plugin-react-refresh";
import path from "path";

export default defineConfig({
	plugins: [reactRefresh()],
	resolve: {
		alias: {
			// 设置项目文件导入路径,分块打包时要先配这个,不然会报错
			"@": path.resolve(__dirname, "./src"),
		},
	},
	build: {
		//分块打包配置
		chunkSizeWarningLimit: 1500,
		rollupOptions: {
			output: {
				manualChunks(id) {
					if (id.includes("node_modules")) {
						return id
							.toString()
							.split("node_modules/")[1]
							.split("/")[0]
							.toString();
					}
				},
			},
		},
	},
});
